import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
import { dateFormatter } from '@/utils/formatTime'

// 表单校验
export const rules = reactive({})

const crudSchemas = reactive<CrudSchema[]>([
  {
    label: 'ID',
    field: 'id',
    isForm: false
  },
  {
    label: 'IP',
    field: 'ip',
    isSearch: true
  },
  {
    label: '地区',
    field: 'ipLocation',
    isSearch: false
  },
  {
    label: '是否被禁止',
    field: 'hasLimit',
    isSearch: false,
    dictType: DICT_TYPE.CMS_STATUS_TYPE,
    dictClass: 'number',
    form: {
      component: 'Radio',
      value: 1
    }
  },
  {
    label: '禁止类型',
    field: 'limitType',
    isSearch: false,
    isTable: false,
    dictType: DICT_TYPE.CMS_IP_LIMIT_TYPE,
    dictClass: 'number',
    form: {
      component: 'Radio',
      value: 1
    }
  },
  {
    label: '访问URL',
    field: 'accessUrl',
    isSearch: false,
    isTable: false
  },
  {
    label: '可疑参数',
    field: 'accessParams',
    isSearch: false,
    isTable: false
  },
  {
    label: '创建时间',
    field: 'createTime',
    formatter: dateFormatter,
    isSearch: false,
    search: {
      component: 'DatePicker',
      componentProps: {
        valueFormat: 'YYYY-MM-DD HH:mm:ss',
        type: 'daterange',
        defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')]
      }
    },
    isForm: false
  },
  {
    label: '操作',
    field: 'action',
    isForm: false
  }
])
export const { allSchemas } = useCrudSchemas(crudSchemas)
